{template 'common/header'}
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>
<ul class="nav nav-tabs">
  <li {if $opp == 'citysetup'}class="active"{/if}><a href="{php echo $this->createWebUrl('citysetup');}">信息库基本设置</a></li>
  <li {if $opp == 'cityclass'}class="active"{/if}><a href="{php echo $this->createWebUrl('cityclass');}">信息库信息分类</a></li>
  <li {if $opp == 'city_overrule'}class="active"{/if}><a href="{php echo $this->createWebUrl('city_overrule');}">信息顶置规则</a></li>
  <li {if $opp == 'citybase'}class="active"{/if}><a href="{php echo $this->createWebUrl('citybase');}">信息库信息管理</a></li>
  <li {if $opp == 'citybanner'}class="active"{/if}><a href="{php echo $this->createWebUrl('citybanner');}">信息库轮播图管理</a></li>
</ul>
</div>
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>
<ul class="nav nav-tabs">
  <li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('citybase', array('op' => 'post'));}">添加信息</a></li>
  <li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('citybase',array('op'=>'display'));}">管理信息</a></li>
</ul>
{if $op =='display'}
<div class="panel panel-success">
  <div class="panel-heading">名片通讯录 >信息管理</div>
</div>
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form">

                <input type="hidden" name="c" value="site" />

                <input type="hidden" name="a" value="entry" />

			<input type="hidden" value="bbyscm_card_cityxinxi" name="m">

			<input type="hidden" value="citybase" name="do">

			<input type="hidden" value="display" name="op">

			<div class="form-group">

		<label class="col-xs-12 col-sm-3 col-md-2 control-label">选择行业</label>

		<div class="col-sm-4">

			<select name="cid1"  class="form-control">

			<option value=""></option>
            {php $cates1 = pdo_fetchall("SELECT * FROM ".tablename('bbyscm_card_cityclass')." where uniacid=$uniacid");}
            
			{php $cate1  = pdo_fetchall("SELECT * FROM ".tablename('bbyscm_card_cityxinxi')." where uniacid=$uniacid");}

			{loop $cates1 $catelist1}

					<option value="{$catelist1['id']}" {if $_GPC['cid1']==$catelist1['id']}selected{/if}>{$catelist1['classname']}</option>

					{/loop}
			</select>
		</div>
	</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2  control-label">关键字</label>
				<div class="col-sm-4">
						<input type="text" placeholder="搜索姓名或手机号" value="{$_GPC['keyword']}" id="" name="keyword" class="form-control">
				</div>				
			</div>
			<div class="form-group">
				<div class="pull-right col-xs-12 col-sm-2">
					<button class="btn btn-block"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
			</form>
		</div>
	</div>

<div style="padding:15px;">

<form id="form2" class="form-horizontal" method="post">

		<table class="table table-hover">

			<thead class="navbar-inner">

				<tr>

				<th style="width:30px;">全选</th>

					<th style="width:100px;">ID</th>

					<th style="width:100px;">发布者</th>

					<th style="width:300px;">信息标题</th>

					<th style="width:120px;">类别</th>

					<th style="width:60px;">头像</th>

					<th style="width:150px;">时间</th>

					<th style="min-width:60px;width:150px;">  审核 | 修改 |  删除</th>

				</tr>

			</thead>

			<tbody>

				{loop $list $item}

				{php $cates = pdo_fetch("SELECT * FROM ".tablename('bbyscm_card_cityclass')." WHERE id='".$item['cityclass']."'");}

				<tr>

				<td><input type="checkbox" value="{$item['id']}" name="delete[]"></td>

					<td>{$item['id']}</td>

					<td><a title='昵称:<?php echo (empty($item['username']))?'':"".$item['username'].""; ?>&#13;Email:<?php echo $item['email'];

echo "&#13;职务:".$item['job']."&#13;公司名称:".$item['company']."&#13;其他职务:".$item['g_job2']."&#13;微信:".$item['weixin']."&#13;公司电话:".$item['mobile2']."&#13;公司地址:".$item['address']."&#13;公司网址:".$item['g_site']."&#13;公司业务:".$item['desc'];

?>' href="javascript:;">{$item['cardname']}</a></td>

					<td>{$item['cityname']}</td>

					<td>{$cates['classname']}</td>

          <td>{if !empty($item['avaterImg'])}<img src="{$item['avaterImg']}" width="50" height="50" />{else}<i class="fa fa-picture-o fa-2x"></i>{/if}</td>

          <td>{php echo date('y-m-d H:i',$item['createtime'])}</td>

					<td>


<a id="id{$item['id']}" href="javascript:shen('{php echo $this->createWebUrl('citybase', array('op' => 'shenhe', 'id' =>$item['id'],'akey'=>$item['akey']))}',{$item['id']});" title="{if $item['akey']==1}关闭{else}通过{/if}" class="shen btn btn-sm {if $item['akey']==0}btn-danger{else}btn-success{/if}"><i class="fa fa-check"></i></a>

					<a href="{php echo $this->createWebUrl('citybase', array('op' => 'post', 'id' => $item['id']))}" title="编辑" class="btn btn-primary btn-sm"><span class="fa fa-edit"></span></a>

					<a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWebUrl('citybase', array('id' => $item['id'],'op'=>'del'))}" title="删除" class="btn btn-sm btn-danger"><span class="fa fa-times" ></span></a>

					</td>				

				</tr>

				{/loop}

				<tr >

				<td><input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>    <input class="btn btn-primary btn-sm" type="submit" value="删除" name="submit" ></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>

				</tr>

			</tbody>

		</table>

		<input type="hidden" value="card" name="do">

		<input type="hidden" value="del" name="op">

		<input type="hidden" name="token" value="{$_W['token']}" />

		</form>

		{$pager}

			<script>

function shen(url,id){

						$.getJSON(url,function(data){

						if(data.a==0){

						$("#id"+id).removeClass('btn-success');

						$("#id"+id).addClass('btn-danger');

						}else if(data.a==1){

						$("#id"+id).removeClass('btn-danger');

						$("#id"+id).addClass('btn-success');

						}

						location.reload();

						})

}

	function isjb(id){

$.ajax({

type: "POST",

url:  "{php echo $this->createWebUrl('citybase', array('op' => 'jb'))}",

data: "id="+id,

dataType:"json",

success: function(msg){

if(msg.status == true)

   {alert('解绑成功');


  location.reload();

   }

   else

   {

 alert('解绑失败');

   }

}

}); 

}
   function isbd(id){

$.ajax({

type: "POST",

url:  "{php echo $this->createWebUrl('accredit', array('op' => 'bd'))}",

data: "id="+id,

dataType:"json",

success: function(msg){
var url = msg.imgUrl;
if(msg.status == true)

   {
	//   alert($('#tuserlink').html('<img  src = '+ url +' style="sposition:relative">'););
    $('#Modal2').modal('toggle');
    $('#tuserlink').html('<img  src = '+ url +'>');
   // location.reload(); 

   }

   else

   {

 alert('绑定失败');


   }

}

}); 

}
	</script>

	<script>


					$('#form2').submit(function(){

if($(":checkbox[name='delete[]']:checked").size() > 0){

return confirm('删除后不可恢复，您确定删除吗？');

}

return false;

}); 

		</script>	

</div>
{elseif $op == 'post'}
<div class="panel panel-success">
  <div class="panel-heading">名片通讯录 >添加信息</div>
</div>

<div class="main">

	<form action="" method="post" class="form-horizontal form">

	<div class="panel panel-default">

		<div class="panel-heading">

		添加/修改信息

		</div>

		<div class="panel-body">

			<div class="form-group">

				<label class="col-sm-2 control-label">发布者姓名<span style="color:red;font-size:18px">*</span></label>

				<div class="col-sm-7">

					<input type="text" name="cardname" class="form-control" value="{$item['cardname']}" /> 

					

				</div>

			</div>

			<div class="form-group">

				<label class="col-sm-2 control-label">发布者手机号<span style="color:red;font-size:18px">*</span></label>

				<div class="col-sm-7">

					<input type="text" name="mobile" class="form-control" value="{$item['mobile']}" /> 				

				</div>

			</div>
            <div class="form-group">

				<label class="col-sm-2 control-label">发布者名片ID<span style="color:red;font-size:18px">*</span></label>

				<div class="col-sm-7">

					<input type="text" name="cardid" class="form-control" value="{$item['cardid']}" /> 				

				</div>

			</div>

			<div class="form-group">

		<label  class="col-sm-2 control-label">头像图片</label>

		<div class="col-sm-7">

			{php echo tpl_form_field_image('avaterImg', $item['avaterImg'] =='' ? $setting['thumb'] : $item['avaterImg']);}

			<span class="help-block">头像图片,大小100X100之内,可以不填,将采用自动同步微信头像</span>

		</div>

	</div>
    
     <div class="form-group">

                <label  class="col-sm-2 control-label">发布的图片</label>

                <div class="col-sm-7">

                 {php echo tpl_form_field_multi_image('imgs', $item['imgs']);}
                 
             </div>

       </div>

			<div class="form-group">

		<label class="col-xs-12 col-sm-3 col-md-2 control-label">信息类别</label>

		<div class="col-sm-7">

			<select name="cityclass"  class="form-control">

			<?php

			$itemarr =  pdo_fetchall("SELECT *  FROM ".tablename('bbyscm_card_cityclass') ."  where  uniacid='$uniacid' ORDER BY id ASC"); 

			foreach($itemarr as $k2=>$v2){

          $selected2 = ($item["cityclass"]==$v2['id'])?"selected":"";

					echo "<option value='".$v2['id']."' $selected2  >".$v2['classname']."</option>";

					}

				?>

			</select>

		</div>

	</div>

				<div class="form-group">

				<label class="col-sm-2 control-label">信息标题</label>

				<div class="col-sm-7">

					<input type="text" name="cityname" class="form-control" value="{$item['cityname']}" />

				</div>

			</div>			
		
			<div class="form-group">

				<label class="col-sm-2 control-label">信息地址</label>

				<div class="col-sm-7">

					<input type="text" name="cityaddress" class="form-control" value="{$item['cityaddress']}" /> 				

				</div>

			</div>

			<div class="form-group">

				<label class="col-sm-2 control-label">信息内容</label>

				<div class="col-sm-7">

					<textarea class="form-control" name="citydesc" rows="5">{$item['citydesc']}</textarea>

				</div>

			</div>

			<div class="form-group">

				<label class="col-sm-2 control-label">地图坐标</label>

				<div class="col-sm-7">

				<?php 

				if(empty($item["longitude"])){

				$map = array('lng'=>116.406955,'lat'=>39.913397);

				}else{

				$map =  array('lng'=>$item["longitude"],'lat'=>$item["latitude"]);

				}

				echo tpl_form_field_coordinate('g_map',$map);

				?>

				</div>

			</div>
            	<div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">审核状态</label>

					<div class="col-sm-9 col-xs-12">

						<label class='radio-inline'>

							<input type='radio' name='akey' value=1' {if $item['akey']==1}checked{/if} /> 通过

						</label>

						<label class='radio-inline'>

							<input type='radio' name='akey' value=0' {if $item['akey']==0}checked{/if} /> 不通过

						</label>

					</div>

				</div>


			<div class="form-group">

				<label class="col-sm-2 control-label">点击率</label>

				<div class="col-sm-7">

					<input type="text" name="popularity" class="form-control" value="{php echo empty($item['popularity'])?0:$item['popularity'];}" /> 				

				</div>

			</div>		

			<div class="form-group">

				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>

				<div class="col-sm-4">

				<input type="hidden" name="id" value="{$item[id]}">

				<input type="hidden" name="token" value="{$_W['token']}" />

				<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
				</div>
			</div>
		</div>
	</div>

	</form>
</div>
{/if}	
</div>


{template 'common/footer'}